package smokesignals.data.db4o;

import com.db4o.ObjectContainer;
import com.db4o.query.Predicate;
import com.googlecode.recycled.lang.assertions.Assert;
import smokesignals.data.QueryHandler;

import java.util.List;


/**
 * @author Henryk Konsek
 */
public class PredicateQueryHandler implements QueryHandler<Predicate> {

    protected ObjectContainer container;

    public PredicateQueryHandler(ObjectContainer container) {
        Assert.notNull(container);

        this.container = container;
    }

    @Override
    @SuppressWarnings("unchecked") // Raw Db4o's Predicate vs generic Iterable<R>
    public <R> List<R> handle(Predicate query, Object... parameters) {
        return container.query(query);
    }

}
